package com.gitee.huanminabc.fastboot.timerwheel.classload;

import com.gitee.huanminabc.jcommon.reflect.ClassUtil;
import com.gitee.huanminabc.fastboot.load.classload.ClassLoadIntercept;
import com.gitee.huanminabc.fastboot.timerwheel.TimerWheelContext;
import com.gitee.huanminabc.jtimerwheel.annotation.TimerWheel;

/**
 * 简要描述
 *
 * @Author: huanmin
 * @Date: 2025/4/13 00:39
 * @Version: 1.0
 * @Description: 文件作用详细描述....
 */
public class TimerWheelClassLoad implements ClassLoadIntercept {

    @Override
    public void peek(Class<?> clazz) throws Exception {
        TimerWheel timerWheel = clazz.getAnnotation(TimerWheel.class);
        if (timerWheel != null) {
            TimerWheelContext.allTimerWheelClasses.add(clazz);
        }
    }

    @Override
    public Object createBean(Class<?> clazz) throws Exception {
        if (clazz.getAnnotation(TimerWheel.class) != null) {
            return ClassUtil.newInstance(clazz);
        }
        return ClassLoadIntercept.super.createBean(clazz);
    }
}
